package com.example.anew.journey.mynewjourney.logic.main;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.example.anew.journey.mynewjourney.R;
import com.example.anew.journey.mynewjourney.adpater.MainViewpagerAdapter;
import com.example.anew.journey.mynewjourney.logic.search.SearchActivity;
import com.example.anew.journey.mynewjourney.logic.main.persenter.MainPersenter;
import com.example.anew.journey.mynewjourney.logic.main.view.ISMainView;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 杭州惟君医疗科技有限公司14
 * Created by 20433 on 2018/3/7
 */

public class MainActivity extends AppCompatActivity  implements ISMainView {
    @Bind(R.id.activity_base_main_toolbar)
    Toolbar activityBaseMainToolbar;
    @Bind(R.id.activity_base_main_tab)
    TabLayout activityBaseMainTab;
    @Bind(R.id.activity_base_main_app_bar)
    AppBarLayout activityBaseMainAppBar;
    @Bind(R.id.activity_base_main_viewpager)
    ViewPager activityBaseMainViewpager;
    @Bind(R.id.activity_base_main_rl_search)
    RelativeLayout activityBaseMainRLSearch;
    @Bind(R.id.activity_base_main_iv_search)
    ImageView activityBaseMainIvSearch;
    private MainViewpagerAdapter mainViewpagerAdapter;
    private MainPersenter mMainPersenter = new MainPersenter(this);


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base_main);
        ButterKnife.bind(this);
        // ButterKnife.bind(this);
        mainViewpagerAdapter = new MainViewpagerAdapter(getSupportFragmentManager());
        activityBaseMainViewpager.setAdapter(mainViewpagerAdapter);
        activityBaseMainTab.setupWithViewPager(activityBaseMainViewpager);
        activityBaseMainViewpager.setCurrentItem(0);
    }

    @OnClick({R.id.activity_base_main_iv_search, R.id.activity_base_main_rl_search})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_base_main_iv_search:
                mMainPersenter.onClickSearchActivity();
                break;
            case R.id.activity_base_main_rl_search:
                mMainPersenter.onClickSearchActivity();
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }
    // 显示提示Toast信息
    @Override
    public void showToastInformation(String str) {

    }
    // 跳转搜索页面
    @Override
    public void toSearchActivity() {
        Intent intent =  new Intent(this,SearchActivity.class);
        startActivity(intent);
    }
}
